package com.sllp.C71S3TsllpShop.config;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.sllp.C71S3TsllpShop.interceptor.AdminInterceptor;
import com.sllp.C71S3TsllpShop.interceptor.BusinessInterceptor;
import com.sllp.C71S3TsllpShop.interceptor.UserInterceptor;

/**
 * 拦截器配置
 * @author 沈俊羽
 *
 */
@SpringBootConfiguration
public class LoginConfig implements WebMvcConfigurer {

	@Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册TestInterceptor拦截器
        InterceptorRegistration registration = registry.addInterceptor(new UserInterceptor());
        registration.addPathPatterns("/**");                      //所有路径都被拦截
        registration.excludePathPatterns(                         //添加不拦截路径
        								 "/*/*.*",
        								 "/*.*",
        								 "/**/*.*",
                                         "/websocket",
                                         "/websocket/**",
                                         "/index",
                                         "/index.do",
                                         "/toLogin.do",
                                         "/loginNow.do",
                                         "/logVerifyCode.do",
                                         "/findProductIndex",
                                         "/product.do",
                                         "/product",
                                         "/toRegist.do",
                                         "/registNow.do",
                                         "/back/*.*",
        								 "/back/**",
        								 "/back/*/*.*",
                                         "/brandlist.do",
                                         "/brandlist",
                                         "/categorylist",
                                         "/categorylist.do",
                                         "/back/toProductFind.do"
                                         ); 

        InterceptorRegistration registrationBusiness = registry.addInterceptor(new BusinessInterceptor());
        registrationBusiness.addPathPatterns("/back/**");                      //所有路径都被拦截
        registrationBusiness.excludePathPatterns(                         //添加不拦截路径
        								"/back/*/*.*",
        								"/back/logVerifyCode.do",
        								"/back/sendBackResetPwdEmail.do",
        								"/back/",
        								"/back/index",
        								"/back/index.*",
        								"/back/loginNow.do",
        								"/back/toLogin.do",
        								"/back/register",
        								"/back/uploadbusinessimg.do"
                                        ); 
    }
}